/**
 * -------------------------------------------------------------------------- *
 * 								ETL Manager
 * 						Monitor | Manage | Admin
 * -------------------------------------------------------------------------- *
 * Type:	com.gs.gms.model.dto.UserDto
 * Date:	Nov 8, 2013  12:58:54 PM
 * 
 * -------------------------------------------------------------------------- *
 */
package com.gs.gms.model.dto;

import com.gs.gms.util.conerter.Conversion;
import com.gs.gms.util.conerter.FieldMapper;

/**
 * @author Sabuj Das | sabuj.das@asia.xchanging.com
 * 
 */
@Conversion(targetClassName="com.gs.gms.model.entity.User")
public class UserDto {

	private Long userId;
	private String userName;
	private String password;
	private String displayName;
	private String firstName;
	private String lastName;
	private String emailAddress;
	private boolean emailIsUserName;

    private UserSessionDto currentSession;
    
	/**
	 * 
	 */
	public UserDto() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param userName
	 * @param password
	 * @param displayName
	 * @param firstName
	 * @param lastName
	 * @param emailAddress
	 * @param emailIsUserName
	 */
	public UserDto(String userName, String password, String displayName,
			String firstName, String lastName, String emailAddress,
			boolean emailIsUserName) {
		this(0, userName, password, displayName, firstName, lastName,
				emailAddress, emailIsUserName);
	}

	/**
	 * @param userId
	 * @param userName
	 * @param password
	 * @param displayName
	 * @param firstName
	 * @param lastName
	 * @param emailAddress
	 * @param emailIsUserName
	 */
	public UserDto(long userId, String userName, String password,
			String displayName, String firstName, String lastName,
			String emailAddress, boolean emailIsUserName) {
		this.userId = userId;
		this.userName = userName;
		this.password = password;
		this.displayName = displayName;
		this.firstName = firstName;
		this.lastName = lastName;
		this.emailAddress = emailAddress;
		this.emailIsUserName = emailIsUserName;
	}

	@FieldMapper(targetFieldName="userId")
	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}
	@FieldMapper(targetFieldName="userName")
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
	@FieldMapper(targetFieldName="password")
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	@FieldMapper(targetFieldName="displayName")
	public String getDisplayName() {
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}
	@FieldMapper(targetFieldName="firstName")
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	@FieldMapper(targetFieldName="lastName")
	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	@FieldMapper(targetFieldName="emailAddress")
	public String getEmailAddress() {
		return emailAddress;
	}

	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}
	
	public boolean isEmailIsUserName() {
		return emailIsUserName;
	}

	public void setEmailIsUserName(boolean emailIsUserName) {
		this.emailIsUserName = emailIsUserName;
	}
	@FieldMapper(targetFieldName="currentSession")
    public UserSessionDto getCurrentSession() {
        return currentSession;
    }

    public void setCurrentSession(UserSessionDto currentSession) {
        this.currentSession = currentSession;
    }

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((emailAddress == null) ? 0 : emailAddress.hashCode());
		result = prime * result
				+ ((userName == null) ? 0 : userName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof UserDto)) {
			return false;
		}
		UserDto other = (UserDto) obj;
		if (emailAddress == null) {
			if (other.emailAddress != null) {
				return false;
			}
		} else if (!emailAddress.equals(other.emailAddress)) {
			return false;
		}
		if (userName == null) {
			if (other.userName != null) {
				return false;
			}
		} else if (!userName.equals(other.userName)) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return String.format("UserDto [userName=%s]", userName);
	}
	
}
